/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package todotask.model;

import java.util.List;
import javax.swing.table.AbstractTableModel;
import todotask.entities.Task;

/**
 *
 * @author dakota
 */
public class TaskTableModel extends AbstractTableModel {

    List tasks;

    public TaskTableModel(List tasks) {
        this.tasks = tasks;
    }

    public TaskTableModel() {
    }

    @Override
    public Class getColumnClass(int columnIndex) {
        return Task.class;
    }

    @Override
    public int getColumnCount() {
        return 1;
    }

    @Override
    public String getColumnName(int columnIndex) {
        return "Tasks";
    }

    @Override
    public int getRowCount() {
        return (tasks == null) ? 0 : tasks.size();
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        return (tasks == null) ? null : tasks.get(rowIndex);
    }

    @Override
    public boolean isCellEditable(int columnIndex, int rowIndex) {
        return true;
    }
}
